package com.lsh.utils;

import org.springframework.stereotype.Component;

@Component
public class LimitUtil {
    private int current = 1;
    private int size = 10;
    private long total;
    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public int getSize() {
        return size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getLimits() {
        if((total % size)==0){
            return (int)total/size;
        }else {
            return  (int)total/size+1;
        }
    }
    public int start(){
        return (current - 3) < 1 ? 1 : (current - 2);
    }
    public int end(){
        int limits = getLimits();
        return (current + 3) > limits ? limits : (current + 2);
    }
}
